# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-cap2
_gemname=cap2
pkgver=0.2.2
pkgrel=4
pkgdesc="Ruby library for managing Linux process and file capabilities"
url="https://github.com/lmars/cap2"
arch="all"
license="MIT"
makedepends="libcap-dev ruby-dev"
checkdepends="ruby-rspec"
source="https://github.com/lmars/cap2/archive/v$pkgver/$pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_gemname-$pkgver"
options="!check"  # FIXME: some tests are broken

build() {
	gem build $_gemname.gemspec
	gem install \
		--local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	GEM_PATH="dist" rspec spec
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r LICENSE Rakefile README.md ext/ lib/*.so spec/
}

sha512sums="
d144b8b51f3568c1307265d06bb0f08a41b96e0f600ccf7dd6f67b6aca880bdb1ebc8338aefc1fd3e8bc218d3a407936efb671c9949d8c77f4429f8cd641a8b1  ruby-cap2-0.2.2.tar.gz
"
